package request

type VpnAddRequest struct {
	Name   string `json:"name" binding:"required,min=2,max=50" label:"VPN名称"`
	Icon   string `json:"icon" binding:"required" label:"VPN图标"`
	Desc   string `json:"desc" label:"VPN描述"`
	Link   string `json:"link" binding:"required" label:"VPN链接"`
	Click  int    `json:"click" label:"点击量"`
	Status int    `json:"status" binding:"oneof=0 1" label:"状态"`
	Sort   int    `json:"sort" label:"排序"`
}

func (r VpnAddRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"name.required": "VPN名称不能为空",
		"name.min":      "VPN名称长度不能小于2",
		"name.max":      "VPN名称长度不能大于50",
		"icon.required": "VPN图标不能为空",
		"link.required": "VPN链接不能为空",
		"status.oneof":  "状态只能是0或1",
	}
}

type VpnEditRequest struct {
	ID     uint   `json:"id" binding:"required" label:"VPN ID"`
	Name   string `json:"name" binding:"required,min=2,max=50" label:"VPN名称"`
	Icon   string `json:"icon" binding:"required" label:"VPN图标"`
	Desc   string `json:"desc" label:"VPN描述"`
	Link   string `json:"link" binding:"required" label:"VPN链接"`
	Click  int    `json:"click" binding:"required" label:"点击量"`
	Status int    `json:"status" binding:"oneof=0 1" label:"状态"`
	Sort   int    `json:"sort" label:"排序"`
}

func (r VpnEditRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"id.required":   "VPN ID不能为空",
		"name.required": "VPN名称不能为空",
		"name.min":      "VPN名称长度不能小于2",
		"name.max":      "VPN名称长度不能大于50",
		"icon.required": "VPN图标不能为空",
		"link.required": "VPN链接不能为空",
		"status.oneof":  "状态只能是0或1",
	}
}

type VpnDeleteRequest struct {
	ID uint `json:"id" binding:"required" label:"VPN ID"`
}

func (r VpnDeleteRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"id.required": "VPN ID不能为空",
	}
}

type VpnGetRequest struct {
	ID uint `json:"id" binding:"required" label:"VPN ID"`
}

func (r VpnGetRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"id.required": "VPN ID不能为空",
	}
}

type VpnListRequest struct {
	Name      string `json:"name" form:"name"`             // VPN名称
	Status    *int   `json:"status" form:"status"`         // 状态
	StartTime string `json:"start_time" form:"start_time"` // 开始时间
	EndTime   string `json:"end_time" form:"end_time"`     // 结束时间
	Page      int    `json:"page" form:"page" binding:"required,gte=1"`
	PageSize  int    `json:"page_size" form:"page_size" binding:"required,gte=1,lte=100"`
}

func (r VpnListRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"page.required":      "页码不能为空",
		"page.gte":           "页码不能小于1",
		"page_size.required": "每页条数不能为空",
		"page_size.gte":      "每页条数不能小于1",
		"page_size.lte":      "每页条数不能大于100",
	}
}
